﻿<%@ Page Title="Room Availability - Delonix Regia" Language="C#" MasterPageFile="~/default.Master" AutoEventWireup="true" CodeBehind="RoomAvailability.aspx.cs" Inherits="DelonixRegia.RoomAvailability" %>

<asp:Content ID="Content4" ContentPlaceHolderID="cphPageTitle" runat="server">
    Room Availability - Delonix Regia
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="cphTitle" runat="server">
    <i class="fa fa-search"></i> Room Availability
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphSubtitle" runat="server">
    Check for Room Availability in Delonix Regia
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="cphMain" runat="server">
    <asp:Panel ID="pnlFirstStep" runat="server">
        <div class="panel panel-default" style="width: 850px; margin: 0 auto;">
            <div class="panel-heading">Check for Room Availability</div>

            <div class="panel-body">
                <div class="alert alert-danger" id="errorBox" style="display: none;">
                </div>
                <table class="nav-justified">
                    <tr>
                        <td colspan="6">
                            <table style="width: 600px;" align="center">
                                <tr>
                                    <td class="text-right" style="width: 164px">Number of Guest(s):</td>
                                    <td style="width: 15px">&nbsp;</td>
                                    <td>
                                        <asp:TextBox ID="tbxNoGuest" runat="server" CssClass="form-control" Width="50px" MaxLength="3"></asp:TextBox>
                                    </td>
                                    <td class="text-center" style="width: 69px"><strong>OR</strong></td>
                                    <td class="text-right" style="width: 170px">Search by Room No.:</td>
                                    <td>&nbsp;</td>
                                    <td>
                                        <asp:TextBox ID="tbxRoomNo" runat="server" CssClass="form-control" Width="72px" MaxLength="5"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td class="text-right" style="color: gray;" colspan="6">
                            <hr />
                        </td>
                    </tr>
                    <tr>
                        <td class="text-right" style="width: 165px; color: gray;"><small>(Optional Parameters)</small></td>
                        <td style="width: 18px">&nbsp;</td>
                        <td style="width: 214px">&nbsp;</td>
                        <td style="width: 184px">&nbsp;</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="text-right" style="width: 165px;">Room Type:</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td style="width: 214px">
                            <asp:DropDownList ID="ddlRoomType" runat="server" CssClass="form-control" Width="188px">
                                <asp:ListItem Selected="True">Not Selected</asp:ListItem>
                                <asp:ListItem Value="1">Single</asp:ListItem>
                                <asp:ListItem Value="2">Queen</asp:ListItem>
                                <asp:ListItem Value="3">Premium Suite</asp:ListItem>
                                <asp:ListItem Value="4">Presidential Suite</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td class="text-right" style="width: 184px;">Smoking/Non-Smoking:</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td>
                            <asp:RadioButtonList ID="rblSmoke" runat="server">
                                <asp:ListItem Value="1">Smoking</asp:ListItem>
                                <asp:ListItem Value="0">Non-Smoking</asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 165px">&nbsp;</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td style="width: 214px">&nbsp;</td>
                        <td style="width: 184px">&nbsp;</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="text-right" style="width: 165px">Balcony:</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td style="width: 214px">
                            <asp:RadioButtonList ID="rblBalcony" runat="server">
                                <asp:ListItem Value="1">Yes</asp:ListItem>
                                <asp:ListItem Value="0">No</asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                        <td class="text-right" style="width: 184px">Low / High Level:</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td>
                            <asp:RadioButtonList ID="rblLevel" runat="server">
                                <asp:ListItem Value="0">Low Level</asp:ListItem>
                                <asp:ListItem Value="1">High Level</asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                    <tr>
                        <td class="text-right" style="width: 165px">&nbsp;</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td style="width: 214px">&nbsp;</td>
                        <td class="text-right" style="width: 184px">&nbsp;</td>
                        <td style="width: 18px">&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="text-center" colspan="6">
                            <asp:Button ID="btnSearch" runat="server" Text="Check" CssClass="btn btn-default btn-lg" OnClientClick="return btnSearch_Click();" OnClick="btnSearch_Click" />
                            <asp:Button ID="btnClear" runat="server" Text="Clear" CssClass="btn btn-default btn-lg" OnClientClick="this.form.reset();return false;" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </asp:Panel>

    <asp:Panel ID="pnlSecondStep" runat="server" Visible="false">
        <div class="panel panel-default" id="secondStep" style="width: 850px; margin: 0 auto;">
            <div class="panel-heading">
                Room Availability
            </div>

            <div class="panel-body">
                <asp:GridView ID="gvResult" runat="server" HorizontalAlign="Center" Width="80%" CssClass="table table-bordered" OnRowDataBound="gvResult_RowDataBound" Font-Bold="False">
                    <EmptyDataTemplate>
                        <asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="Red" Text="No rooms found for the given criteria!"></asp:Label>
                    </EmptyDataTemplate>
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:HyperLink ID="hlBook" runat="server" NavigateUrl='<%# "RoomBooking.aspx?roomNo=" +  Eval("RoomNumber") %>'>Book</asp:HyperLink>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataRowStyle HorizontalAlign="Center" />
                    <HeaderStyle HorizontalAlign="Center" />
                    <RowStyle HorizontalAlign="Center" />
                </asp:GridView>
            </div>
            <div style="text-align:center"><asp:Button ID="btnGoBack" runat="server" Text="< Go back" CssClass="btn btn-default btn-lg" OnClick="btnGoBack_Click" /></div><br />
        </div>
    </asp:Panel>

    <script type="text/javascript">
        function transitionToSecondStep() {
            $('#secondStep').hide().show('slide', { direction: 'right', easing: 'easeOutQuart', duration: 250 });
        }

        function btnSearch_Click() {
            var NoGuest = $('#cphMain_tbxNoGuest').val();
            var RoomNo = $('#cphMain_tbxRoomNo').val();

            if ((NoGuest.length == 0) && (RoomNo.length == 0)) {
                $('#errorBox').html('<strong>Error:</strong> You need to enter either the <i>number of guest</i> or <i>room number</i>!');
                $('#errorBox').hide().show();
                return false;
            }

            if ((is_int(NoGuest) != true) || (is_int(RoomNo) != true)) {
                $('#errorBox').html('<strong>Error:</strong> Invalid datatype! You need to enter a number.');
                $('#errorBox').hide().show();
                return false;
            }
        }

        $('#cphMain_tbxNoGuest').focus().keydown(function () {
            $('#errorBox').hide();
        });

        $('#cphMain_tbxRoomNo').keydown(function () {
            $('#errorBox').hide();
        });

        function is_int(value) {
            for (i = 0 ; i < value.length ; i++) {
                if ((value.charAt(i) < '0') || (value.charAt(i) > '9')) return false;
            }
            return true;
        }
    </script>
</asp:Content>
